package com.xhh.nphm.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xhh.nphm.system.domain.TtelGetDealEty;
import com.xhh.nphm.system.domain.TworkFormBaseEty;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface TelWFManageDao extends BaseMapper<TworkFormBaseEty> {

    /**
     * 承办单位处理中
     * @param tworkFormBaseEty
     * @return
     */
    @Select("select pkId,GetDealPK,workFormNo," +
            "setProId,wsTopic,fmAreaName,fromName,fromTelA,dfmClaName," +
            "convert(varchar(19),IptTime,20) as iptTime," +
            "openFrom,convert(varchar(10),WfLimit,20) as lmtDate," +
            "crtStepName,PkId as opMdy from tWorkFormBase where CrtStepID in (400,401,500,501,550,551) " +
            "[[and workFormNo = #{workFormNo}]]" +
            "[[and fromName =#{fromName}]]" +
            "[[and fmAreaName =#{fmAreaName}]] " +
            " and IsDel=0  order by PkId desc")
    List<TworkFormBaseEty> listSendOver(TworkFormBaseEty tworkFormBaseEty);

    /**
     * 待再次整理
     * @param tworkFormBaseEty
     * @return
     */
    @Select("select PkId,WorkFormNO," +
            "SetProID,WsTopic,FmAreaName,FromName,FromTelA,DFmClaName," +
            "convert(varchar(19),IptTime,20) as fmTime,OpenFrom," +
            "convert(varchar(10),WfLimit,20) as lmtDate,CrtStepName,tWorkFormBase.PkId as myOP," +
            "(select top 1 SUserName from tWfSendBack where tWorkFormBase.PkId=tWfSendBack.WfId and isDel=0 and SendState = 40 and SeqCode='10' and SUserName!='') as SUserName," +
            "(select top 1 OpUserNo from tWorkFormLog where tWorkFormLog.OpAction = '审核退回工单' and WsDesc like '%(通过)%' and tWorkFormBase.PkId = tWorkFormLog.WfId) as OpUserNo " +
            "from tWorkFormBase where CrtStepID in (120) and IsDel=0 and CrtStepName='再次整理'" +
            " [[and fromName =#{fromName}]]" +
            " [[and workFormNo = #{workFormNo}]] [[and fmAreaName =#{fmAreaName}]] order by mark desc,pkid desc")
    List<TworkFormBaseEty> listSecond(TworkFormBaseEty tworkFormBaseEty);
}
